Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FormData clone boundary inconsistency issue #2305

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

helloliuyiming
Copy link

Resolves #2303

Fix boundary inconsistency in FormData.clone method

Description:

This PR addresses an issue where cloning FormData objects resulted in different boundaries each time. The problem was caused by allocating a new boundary for each clone without any boundary reuse logic.

Changes made:

  • Added an initBoundary parameter to the FormData constructor.
  • Implemented boundary reuse logic when cloning FormData objects.
  • Updated documentation to explain how initBoundary affects boundaryName.

Technical details:

  • The FormData constructor now accepts an optional initBoundary parameter.
  • When initBoundary is provided, it overrides the boundaryName configuration.
  • The cloning process now reuses the existing boundary when appropriate.

Impact:
This fix ensures consistent behavior when cloning FormData objects and improves efficiency by reusing boundaries where possible. It should resolve issues related to unexpected boundary changes during FormData manipulation.

Testing:

  • Added unit tests to verify boundary consistency across cloned FormData objects.
  • Manually tested with various use cases to ensure backwards compatibility.

Note to reviewers:
Please pay special attention to the boundary reuse logic and any potential side effects on existing FormData usage.

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to directly update the _boundary after the construction, so we don't need an extra argument for the constructor which won't increase the complexity for usages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve FormData Clone Method to Maintain Boundary Consistency and Resolve Signature Verification Issues
2 participants